package com.fone.player.play.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.fone.player.ApplicationManage;
import com.fone.player.R;

/**
 * 音轨菜单适配器
 * 
 * @author kongxiaojun
 * @since 2014-5-21
 */
public class MenuTrackAdapter extends BaseAdapter {

	/**
	 * 音轨 菜单
	 */
	private List<String> items;
	/**
	 * 当前是第几个
	 */
	private int currentItem;

	public MenuTrackAdapter(List<String> items, int currentItem) {
		super();
		this.items = items;
		this.currentItem = currentItem;
	}

	@Override
	public int getCount() {
		if (items == null) {
			return 0;
		}
		return items.size();

	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		String sub = items.get(position);
		convertView = LayoutInflater.from(ApplicationManage.getAplicationManageInstance()).inflate(R.layout.player_full_second_menu_item, null);
		TextView tv = (TextView) convertView.findViewById(R.id.second_menu_3d_text);
		View divider = convertView.findViewById(R.id.second_menu_3d_divider);
		if (currentItem == position) {
			tv.setTextColor(ApplicationManage.getAplicationManageInstance().getResources().getColor(R.color.video_info_tab_line));
		} else {
			tv.setTextColor(ApplicationManage.getAplicationManageInstance().getResources().getColor(R.color.white));
		}
		if(sub.trim().equals("und")){
			tv.setText(R.string.nothing);
		}else if(sub.trim().equals(ApplicationManage.getAplicationManageInstance().getString(R.string.nothing))){
			tv.setText(sub);
		}else {
			tv.setText(ApplicationManage.getAplicationManageInstance().getString(R.string.video_fullscreen_track)+(position+1));
		}
		if (position == getCount() - 1) {
			divider.setVisibility(View.GONE);
		} else {
			divider.setVisibility(View.VISIBLE);
		}
		return convertView;
	}

}
